@include('head')
<body class="lay-blog">
@include('title')
<div class="container-wrap">
    <div class="container">
        <div class="contar-wrap">
            {{--<h4 class="item-title">--}}
                {{--<p><i class="layui-icon layui-icon-speaker"></i>公告：<span>欢迎来到我的轻博客</span></p>--}}
            {{--</h4>--}}
            @foreach ($article as $v)
                <div class="item">
                    <div class="item-box  layer-photos-demo1 layer-photos-demo">
                        <h3><a href="details.html">{{$v->title}}</a></h3>
                        <h5>发布于：<span>{{$v->created_at}}</span></h5>
                        <p>{{$v->content}}</p>
                        <img src="res/static/images/item.png" alt="">
                    </div>
                    <div class="comment count">
                        <a href="details.html#comment">评论</a>
                        <a href="javascript:;" class="like">点赞</a>
                    </div>
                </div>
            @endforeach
        </div>
    </div>
</div>
@include("footer")
<script>
    layui.define(['element', 'form','laypage','jquery','laytpl'],function(exports){
        var element = layui.element
            ,form = layui.form
            ,laypage = layui.laypage
            ,$ = layui.jquery
            ,laytpl = layui.laytpl;


        //statr 分页

        //规则tips
        var tip_index = 0;
        $(document).on('mouseenter', '.layui-badge-rim', function(){
            tip_index=layer.tips($('.layer_notice').html(), '.layui-badge-rim', {
                tips: [4, '#D8D8D8'],
                area: ['auto', 'auto'],
                time: 50000
            });
        }).on('mouseleave', '.layui-badge-rim', function(){
            layer.close(tip_index);
        });



        // end 分頁
        // start 导航显示隐藏

        $("#mobile-nav").on('click', function(){
            $("#pop-nav").toggle();
        });

        (function ($) {
            $.extend({
                tipsBox: function (options) {
                    options = $.extend({
                        obj: null,  //jq对象，要在那个html标签上显示
                        str: "+1",  //字符串，要显示的内容;也可以传一段html，如: "<b style='font-family:Microsoft YaHei;'>+1</b>"
                        startSize: "12px",  //动画开始的文字大小
                        endSize: "30px",    //动画结束的文字大小
                        interval: 600,  //动画时间间隔
                        color: "red",    //文字颜色
                        callback: function () { }    //回调函数
                    }, options);

                    $("body").append("<span class='num'>" + options.str + "</span>");

                    var box = $(".num");
                    var left = options.obj.offset().left + options.obj.width() / 2;
                    var top = options.obj.offset().top - 10;
                    box.css({
                        "position": "absolute",
                        "left": left + "px",
                        "top": top + "px",
                        "z-index": 9999,
                        "font-size": options.startSize,
                        "line-height": options.endSize,
                        "color": options.color
                    });
                    box.animate({
                        "font-size": options.endSize,
                        "opacity": "0",
                        "top": top - parseInt(options.endSize) + "px"
                    }, options.interval, function () {
                        box.remove();
                        options.callback();
                    });
                }
            });
        })($);

        function niceIn(prop){
            prop.find('i').addClass('niceIn');
            setTimeout(function(){
                prop.find('i').removeClass('niceIn');
            },1000);
        }

        $(function () {
            $(".like").on('click',function () {

                if(!($(this).hasClass("layblog-this"))){
                    this.text = '已赞';
                    $(this).addClass('layblog-this');
                    $.tipsBox({
                        obj: $(this),
                        str: "+1",
                        callback: function () {
                        }
                    });
                    niceIn($(this));
                    layer.msg('点赞成功', {
                        icon: 6
                        ,time: 1000
                    })
                }
            });
        });
        $('#LAY-msg-box').on('click', '.info-img', function(){
            $(this).addClass('layblog-this');
        })
    });


</script>
</body>
</html>